Skip to content

[release/5.0-rc2] SafeSocketHandle: avoid potential blocking of finalizer thread - #41747

Merged
antonfirsov merged 10 commits into
release/5.0-rc2from
backport/pr-41508-to-release/5.0-rc2
Sep 8, 2020
Merged

[release/5.0-rc2] SafeSocketHandle: avoid potential blocking of finalizer thread#41747
antonfirsov merged 10 commits into
release/5.0-rc2from
backport/pr-41508-to-release/5.0-rc2

Conversation

@github-actions

@github-actions github-actions Bot commented Sep 2, 2020

Copy link
Copy Markdown
Contributor

Backport of #41508 to release/5.0-rc2

/cc @antonfirsov @tmds

Already approved and merged for RC1: #41668

Customer Impact

This fixes a critical bug, where sockets could hang the finalizer thread:

Testing

A test has been added based on the simple repro.

Risk

Low. A finalizer run during a blocking socket operation might be problematic, but this seems to be impossible or very unlikely, since such a call implies a live socket reference, which will prevent finalizer execution.

tmds added 10 commits September 2, 2020 16:59
When the Socket is Disposed, it attempts to make all on-going operations
abort. It does this in a loop, and decides there are no on-going operations
when the reference count becomes zero and the handle gets released.

SafePipeHandle holds a reference to SafeSocketHandle. This prevents the
reference count to drop to zero, and causes the dispose to loop infinitly.

When the Socket is disposed from the finalizer thread, it is no longer used
for operations and we can skip the loop. This avoids blocking the finalizer
thread when the reference count can't drop to zero.
@ghost

ghost commented Sep 2, 2020

Copy link
Copy Markdown

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

@antonfirsov

antonfirsov commented Sep 3, 2020

Copy link
Copy Markdown
Contributor

CreateSocket.CtorAndAccept_SocketNotKeptAliveViaInheritance failure is unrelated, because the test failed already in the past and only with low frequency -- see #41794 for details.

Opened bug #41794 tracking

/cc @tmds

@antonfirsov

Copy link
Copy Markdown
Contributor

/azp run runtime

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@antonfirsov

Copy link
Copy Markdown
Contributor

The mono System.Collections.Concurrent failures are not related (not using sockets) and (probably) covered by #37186 .

@danmoseley

Copy link
Copy Markdown
Contributor

No approval needed to merge into RC2 any change that is already in RC1. In fact @Anipik is planning anyway to make sure everything is merged.

@antonfirsov
antonfirsov merged commit 482494f into release/5.0-rc2 Sep 8, 2020
@jkotas
jkotas deleted the backport/pr-41508-to-release/5.0-rc2 branch September 8, 2020 20:52
@karelz karelz added this to the 5.0.0 milestone Sep 10, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants